

using namespace std;

#include <iostream>
#include "a_star.h"
#include <vector>
#include <queue>
#include <algorithm>

Node::Node() {
	this->bestParent = NULL;
	this->g = 0;
	this->h = 0;
}
Node::Node(int g, int h) {
	this->bestParent = NULL;
	this->g = g;
	this->h = h;
	calcF();
}
double Node::getG(void) {
	return this->g;
}
double Node::getH(void) {
	return this->h;
}
double Node::getF(void) {
	return this->f;
}
void Node::setG(int g) {
	this->g = g;
	calcF();
}
void Node::setH(int h) {
	this->h = h;
	calcF();
}
void Node::calcF(void) {
	this->f = this->g + this->h;
}
void Node::setParent(Node* parent) {
	this->bestParent = parent;
}
Node* Node::getBestParent(void) {
	return this->bestParent;
}
void Node::insertChild(Node* newChild) {
	this->children.push_back(newChild);
}
vector<Node*> Node::getChildren(void) {
	return children;
}
bool Node::getIsSolution(void){
	return isSolution;
}

void Node::calcValue(void){
	int num = numbers[0]*1000 + numbers[1]*100 + numbers[2]*10 + numbers[3];
	int den = numbers[4]*10000 + numbers[5]*1000 + numbers[6]*100 + numbers[7]*10 + numbers[8];

	this->value = num/den;
}

double Node::heuristicFunc(void) {
	return 10;
}
void Node::makeNodeChildren(void) {
	Node child1 = new Node;
	Node child2 = new Node;
	for (int i = 0; i < 2; i++) {
		int temp = 
		numerator[randI] = numerator[randII];
		numerator[randII] = temp;
	}
	

}

bool operator < (const Node& n1, const Node& n2) { 
	return n1.f > n2.f; // Swapped so that priority queue works with the lowest on top
}

string reconstructPath(void){
	return "GOOOOOOOOAAAAAAAAAAL!";
}

string aStarPath (int searchProblem, int herusticFuncH) {
	// Create open_node_list as two priority queues. Two because than you can alter the priority of a given node.
	priority_queue<Node> openSet[2];
	// Index. Which of the lists are active
	int openSetIndex = 0;
	//A vector containing all the closed nodes
	vector<Node> closedSet;

	// Create start node
	Node startNode(0,0); // SETH()? From the heuristic function sent in?
	// Insert startNode into priority queue
	openSet[openSetIndex].push(startNode);	

	while(!openSet[openSetIndex].empty()) {
		// Pop node from openSet with the lowest f
		Node currentNode = openSet[openSetIndex].top(); 
		cout << "Dette er verdien: " << currentNode.getF() << endl;

		if(currentNode.getIsSolution()){
			//return reconstructPath();
		}

		openSet[openSetIndex].pop();

		closedSet.push_back(currentNode);
		
		Node currentChild;



		//If node is a solution, return n from the dark side.

		//For all m in delta? What the?  //Ill be back!

		//Insert node n back into open_nodes with new priority

	}
	return ""; //Failed!
}






